package com.project.util;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

/**
 * @Title: LocalDateChange
 * @Package: com.project.util
 * @Description:
 * @Author: Liang-Xie
 */
@SuppressWarnings("all")
@Component
public class LocalDateChange implements Converter<String, LocalDate> {
    @Override
    public LocalDate convert(String source) {
        if (source != null && source.matches("[/d]{4}-[0-9]{2}-[0-9]{2}")) {
            return LocalDate.parse(source);
        }
        return null;
    }
}